import sys

pentagonals = [n*(3*n-1)/2 for n in range(1,10000)]

pentagonal_set = set(pentagonals)

for i in pentagonals:
    for j in pentagonals:
        k = i + j
        if k in pentagonal_set and k+j in pentagonal_set:
            print i
            sys.exit(0)


